﻿package net.wangit.view.unit.grid;
/**
 * 滚轮，常用于table隔行变色
 * @author watson
 *
 */
public class Wheel {

	private String[] desc;
	private int step;
	private int length;

	public Wheel(String[] desc) {
		this.desc = null;
		step = -1;
		length = 1;
		this.desc = desc;
		if (desc != null) {
			length = desc.length;
		}
	}

	public void reset() {
		step = -1;
	}

	public String get(int i) {
		if (desc == null) {
			return "";
		} else {
			step += i;
			step = step >= 0 ? step : 0;
			return desc[step % length];
		}
	}
}
